package io.sage.config;

import java.net.URLEncoder;

import io.sage.common.utils.HttpUtil;


/**
 * 验证码通知短信接口
 * 
 * @ClassName: IndustrySMS
 * @Description: 验证码通知短信接口
 *
 */
public class IndustrySMS
{
	private static String operation = "/industrySMS/sendSMS";
	private static String accountSid = Config.ACCOUNT_SID;
//	private static String to = "17600377390";
	private static String sig = "【sage考试系统】";
//	private static String smsContent = sig+"登录验证码：123，如非本人操作，请忽略此短信。";

	/**
	 * 验证码通知短信,
	 * operation = "/industrySMS/sendSMS";
	 * accountSid = Config.ACCOUNT_SID;
	 * to = "17600377390";
	 * sig = "【sage考试系统】";
	 * smsContent = sig+"登录验证码：123，如非本人操作，请忽略此短信。";
	 */
	public static String execute(String to,String code)
	{
		
		String smsContent=sig+"登录验证码："+code+"，如非本人操作，请忽略此短信。";
		String tmpSmsContent = null;
	    try{
	      tmpSmsContent = URLEncoder.encode(smsContent, "UTF-8");
	    }catch(Exception e){
	      
	    }
	    String url = Config.BASE_URL + operation;
	    String body = "accountSid=" + accountSid + "&to=" + to + "&smsContent=" + tmpSmsContent
	        + HttpUtil.createCommonParam();

	    // 提交请求
	    String result = HttpUtil.post(url, body);
//	    System.out.println("result:" + System.lineSeparator() + result);
	    
		return result;
	}


}
